package com.priv.dao;

import com.priv.domain.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author : 十一
 * @data : 13:05 2022/12/28
 * When in doubt, use brute force.
 */
public interface BookDao {

    @Insert("insert into tbl_book(type, name, description) values (#{type}, #{name}, #{description})")
    public int save(Book book);

    @Update("update tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")
    public int update(Book book);

    @Delete("delete from tbl_book where id = #{id}")
    public int delete(Integer id);

    @Select("select * from tbl_book where id = #{id}")
    public Book findById(Integer id);

    @Select("select * from tbl_book")
    public List<Book> findAll();
}
